#include "csapp.h"

int main(int argc, char **argv)
{
  int clientfd,port1;
  char *host, *port, buf[MAXLINE];
  rio_t rio;
  
  if(argc != 3) {
    fprintf(stderr,"usage:%s <host><post>\n",argv[0]);
	exit(0);
  }
  host = argv[1];
  port = argv[2];

  port1 = atoi(port);
  
  clientfd = Open_clientfd(host, port1);
  Rio_readinitb(&rio,clientfd);
  
  while(Fgets(buf,MAXLINE,stdin)!=NULL) {
    Rio_writen(clientfd,buf,strlen(buf));
    Rio_readlineb(&rio,buf,MAXLINE);
	Fputs(buf,stdout);
  }
  Close(clientfd);
  exit(0);

}
